﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.MoveToLocation.CUiMoveToLocationCmd
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System.Resources;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.MoveToLocation;

public class CUiMoveToLocationCmd : TxToggleButtonCommand
{
  private CApMoveToLocationEnable m_moveToLocatEnabler;
  private CCApMoveToLocationApp m_moveToLocApp;
  private bool m_pressed;

  public CUiMoveToLocationCmd() => this.m_moveToLocatEnabler = new CApMoveToLocationEnable();

  public virtual void Execute(object cmdParams)
  {
    Cursor current = Cursor.Current;
    Cursor.Current = Cursors.WaitCursor;
    try
    {
      if (this.m_moveToLocApp == null)
        this.m_moveToLocApp = new CCApMoveToLocationApp();
      if (!this.Pressed)
      {
        this.Pressed = !this.Pressed;
        this.m_moveToLocatEnabler.IsCommandStrated = true;
        this.m_moveToLocApp.Play();
        this.m_moveToLocatEnabler.IsCommandStrated = false;
        this.Pressed = !this.Pressed;
      }
      else
      {
        this.m_moveToLocApp.Stop();
        this.m_moveToLocatEnabler.IsCommandStrated = false;
        this.Pressed = true;
      }
    }
    finally
    {
      Cursor.Current = current;
      this.NotifyCommandExecuted();
    }
  }

  public virtual string Category => this.GetResourceManager().GetString("CATEGORY");

  public virtual string Name => this.GetResourceManager().GetString("NAME");

  public virtual string Tooltip => this.GetResourceManager().GetString("TOOLTIP");

  public virtual string Description => this.GetResourceManager().GetString("DESCRIPTION");

  public virtual string Bitmap => "MoveToLocation.move_loc.bmp";

  public virtual string LargeBitmap => "MoveToLocation.move_loc_LARGE.png";

  public virtual ITxImage Image => (ITxImage) TxImageManager.GetImageByKey("MoveToLocation");

  public virtual ITxCommandEnabler CommandEnabler => (ITxCommandEnabler) this.m_moveToLocatEnabler;

  private ResourceManager GetResourceManager()
  {
    return new ResourceManager("DnProcessSimulateCommands.MoveToLocation.StringTable", ((object) this).GetType().Assembly);
  }

  public virtual bool Push => this.Pressed;

  public bool Pressed
  {
    get => this.m_pressed;
    set => this.m_pressed = value;
  }

  public virtual bool Connect() => true;

  public virtual bool Licensed => TxCommandLicenser.MoveToLocationLicense;

  private void NotifyCommandExecuted()
  {
    new TxCommandManager().NotifyCommandExecuted((ITxCommand) this);
  }
}
